package com.hzhc.controller.baseinfo;


import com.hzhc.common.BaseController;
import com.hzhc.entity.VideoPointInfo;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.VideoPointInfoService;
import com.hzhc.utils.ResultUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 监控点信息 前端控制器
 * </p>
 *
 * @author oyd
 * @since 2023-12-15
 */
@Controller
@RequiredArgsConstructor
@RequestMapping("/videoPointInfo")
public class VideoPointInfoController extends BaseController {
    private final VideoPointInfoService videoPointInfoService;

    @RequestMapping("/play/{id}")
    public String play(@PathVariable("id") long id, Model model) {
        if (id == 1) {
            VideoPointInfo pointInfo = videoPointInfoService.getById(1);
            VideoPointInfo pointInfo2 = videoPointInfoService.getById(2);
            model.addAttribute("jk", pointInfo);
            model.addAttribute("ck", pointInfo2);
        } else {
            VideoPointInfo pointInfo = videoPointInfoService.getById(3);
            VideoPointInfo pointInfo2 = videoPointInfoService.getById(4);
            model.addAttribute("jk", pointInfo);
            model.addAttribute("ck", pointInfo2);
        }

        return "basicinfo/videoPointInfo/play";
    }

    @RequestMapping("/getVideoById/{id}")
    @ResponseBody
    public ResultUtil<VideoPointInfo> getVideoById(@PathVariable("id") long id) {
        VideoPointInfo videoPointInfo = videoPointInfoService.getById(id);
        return ResultUtil.build(videoPointInfo, ResultUtilCodeEnum.SUCCESS);
    }

    @RequestMapping("/movePlay/{id}")
    public String movePlay(@PathVariable("id") long id, Model model) {
        VideoPointInfo pointInfo = videoPointInfoService.getById(id);
        model.addAttribute("vo", pointInfo);
        return "video/playFlv";
    }
}
